import { C_IsTry } from "../../C_Config";
import C_Game from "../../C_Game";
import C_App from "../../core/C_App";
import { C_NotificationConst } from "../../core/C_NotificationConst";
import C_SoundManager, { SoundName } from "../../core/utils/C_SoundManager";
import BaseView from "./C_BaseView";

const { ccclass, property } = cc._decorator;
/** 螺丝箱子 */
@ccclass
export default class C_FailedView extends BaseView {

    protected onLoad(): void {
        if (C_IsTry) {
            if (cc.sys.platform === cc.sys.WECHAT_GAME) {
                cc.tween(this.node)
                    .delay(2)
                    .call(() => {
                        C_Game.instance.endTryGame();
                    })
            }
        }
    }

    initView() {
        C_SoundManager.instance.playEffect(SoundName.Failed);

    }

    onTouchEnd() {
        if (C_IsTry) {
            C_App.NotificationCenter.dispatch(C_NotificationConst.BACK_CUSTOMS, true)
            C_Game.instance.endTryGame();

        }
        else {
            C_App.NotificationCenter.dispatch(C_NotificationConst.BACK_CUSTOMS, true)
        }
    }

}
